import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    counter: 520
  },
  mutations: {
    ADD (state ,step) {
      console.log(step)
      state.counter += step
    },
    SUB (state ,payload) {
      console.log(payload)
      state.counter += payload.payload.step
    },
  },
  actions: {
    asyncAdd (store, step) {
      setTimeout ( function () {
        store.commit("ADD",step);
      }, 2000);
    }
  },
  modules: {
  }
})
